/**
 * @author: h'zh
 * @date: 12.14
 */
import Vue from 'vue'
import Router from 'vue-router'
import Layout from "../views/layout/Layout";
import term from "../views/admin/types/typeList";
import studentList from "../views/admin/student/studentList";

//TODO:配置路由,找图标

Vue.use(Router)
/***
 * !!!! important 修改/添加 路由需要同时配置java端的 PermissionService中的 权限控制逻辑
 */

/**
 * hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
 *                                if not set alwaysShow, only more than one route under the children
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
 **/

export const constantRouterMap = [
    {path: '/user/login', component: () => import('../views/login/index'), hidden: true},
    {path: '/user/signup', component: () => import('../views/login/register'), hidden: true},
    {path: '/404', component: () => import('../views/404'), hidden: true},
    {
        path: '',
        component: Layout,
        redirect: '/home',
        children: [
            {
                path: 'home',
                name: 'home',
                component: () => import('../views/home/index'),
                meta: {title: '首页', icon: 'home'}
            }
        ]
    }
]

export const asyncRouterMap = [
    {
        path: '/admin/studentList',
        component: Layout,
        children: [
            {
                path: '', // 学生信息列表
                name: 'studentList',
                component: () => import('../views/admin/student/studentList'),
                meta: {title: '用户管理', icon: 'user-group'}
            },
        ]
    },
    {
        path: '/admin/goodList',
        component: Layout,
        children: [
            {
                path: '', // 商品列表
                name: 'goodList',
                component: () => import('../views/admin/goods/goodList'),
                meta: {title: '商品管理', icon: 'location-shopping'}
            }
        ]
    },
    {
        path: '/admin/requestList',
        component: Layout,
        children: [
            {
                path: '',
                name: 'requestList',
                component: () => import('../views/admin/requests/requestList'),
                meta: {title: '需求管理', icon: 'exclamation-outline'},
            }
        ]
    },
    {
        path: '/admin/typeList',
        component: Layout,
        children: [
            {
                path: '',
                name: 'typeList',
                component: () => import('../views/admin/types/typeList'),
                meta: {title: '类型管理', icon: 'product-cate'},
            }
        ]
    },
    // 用户
    {
        path: '/student/Goods',
        component: Layout,
        children: [
            {
                path: '',
                name: 'Goods',
                component: () => import('../views/student/Goods'),
                meta: {title: '商品', icon: 'location-shopping'},
            }
        ]
    },
    {
        path: '/student/Requests',
        component: Layout,
        children: [
            {
                path: '',
                name: 'Requests',
                component: () => import('../views/student/Requests'),
                meta: {title: '需求', icon: 'exclamation-outline'},
            }
        ]
    },
    {
        path: '/student/Management',
        component: Layout,
        redirect: '/student/Management/personalInfo',
        name:'Management',
        meta: {title: '个人管理', icon: 'user'},
        children: [
            {
                path: 'personalInfo',
                name: 'personalInfo',
                component: () => import('../views/student/Management/personalInfo'),
                meta: {title: '个人信息', icon: 'information-outline'}
            },
            {
                path: 'goodManage',
                name: 'goodManage',
                component: () => import('../views/student/Management/goodManage'),
                meta: {title: '我的商品', icon: 'location-shopping'},
            },
            {
                path: 'requestManage',
                name: 'requestManage',
                component: () => import('../views/student/Management/requestManage'),
                meta: {title: '我的需求', icon: 'exclamation-outline'},
            },
            {
                path: 'accountManage',
                name: 'accountManage',
                component: () => import('../views/student/Management/accountManage'),
                meta: {title: '账号管理', icon: 'key'},
            }
        ]
    },
    {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})
